package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo2 {
    public static void main(String[] args) {
        //Collection c = new HashSet();
        Collection c = new ArrayList();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(9,10));

        //添加
        boolean b = c.add(new Point(1,2));
        System.out.println(b);
        System.out.println(c);
        //判断是否包含
        Point p = new Point(10,2);
        boolean contains = c.contains(p);
        System.out.println(contains);
        System.out.println(c);

        //取消集合中的元素
        Point r = new Point(1,2);
        boolean remove = c.remove(r);
        System.out.println(remove);
        System.out.println(c);

        //包含
        Collection p1 = new ArrayList();
        p1.add(new Point(1,2));
        p1.add(new Point(5,6));
        p1.add(new Point(7,8));
        boolean con = c.containsAll(p1);
        System.out.println("p1:"+p1);
        System.out.println("c:"+c);
        System.out.println("是否包含:"+con);

        //删取交集
        /*
        Collection c1 = new ArrayList();
        c1.add(new Point(3,4));
        c.retainAll(c1);
        System.out.println("c:"+c);
        System.out.println("c1:"+c1);

         */
        Collection c1 = new ArrayList();
        c1.add(new Point(3,4));
        c.removeAll(c1);
        System.out.println("c:"+c);
        System.out.println("c1:"+c1);






    }
}
